#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int n, num = 1, a[100][100] = { 0 };
    scanf("%d", &n);
    int k = n, i = n - 1, j = 0;

    while (k)
    {
        k--;
        while (i < n)  //每次斜着打印一排
        {
            a[i][j] = num;
            i++, j++;  //往右下方移一格
            num++;
        }
        i = k - 1;
        j = 0;
    }

    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            if (a[i][j] != 0)
                printf("%5d", a[i][j]);
        }
        printf("\n");
    }
    return 0;
}